<%--
 * (c)2010-2011 Andrea Caltroni (andrea.caltroni@pd.infn.it), INFN (www.infn.it)
 *
 * This file is part of the IGI Survey Portlet (from here on shortened to IGISP).
 * IGISP is free software: you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by the Free 
 * Software Foundation, either version 3 of the License, or (at your option) any 
 * later version.
 *
 * IGISP is distributed in the hope that it will be useful, but WITHOUT ANY 
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with IGISP. If not, see <http://www.gnu.org/licenses/>.
 *
--%>

<%@ include file="./init.jsp" %>

<% pageContext.setAttribute("newLineChar", "\n"); %>
<% pageContext.setAttribute("newLineHtml", "<br />"); %>

<c:set var="firstElemIdx" value="${pagedListHolder.firstElementOnPage}" />

<%-- // use our pagedListHolder --%>
<jsp:useBean id="pagedListHolder" scope="request" 
   type="org.springframework.beans.support.PagedListHolder"/>

<%-- // create link for pages, "~" will be replaced 
   later on with the proper page number
--%>
<portlet:renderURL var="pagedLink">
    <portlet:param name="action" value="viewUserDescriptions"/>
    <portlet:param name="answerID" value="${answer.id}"/>
    <portlet:param name="p" value="~"/>
</portlet:renderURL>

<h3><spring:message code="userDescriptions.view.title"/></h3>
<table class="lfr-table">
    <tr>
        <th><spring:message code="survey.label.survey"/>:</th>
        <td><a href="<portlet:renderURL><portlet:param name="action" value="viewSurvey"/><portlet:param name="surveyID" value="${answer.question.survey.id}"/></portlet:renderURL>">${answer.question.survey.name}</a></td>
    </tr>
    <tr>
        <th><spring:message code="survey.label.question"/>:</th>
        <td><c:out value="${fn:replace(answer.question.description, newLineChar, newLineHtml)}" escapeXml="false" /></td>
    </tr>
    <tr>
        <th><spring:message code="survey.label.answer"/>:</th>
        <td><c:out value="${fn:replace(answer.description, newLineChar, newLineHtml)}" escapeXml="false" /></td>
    </tr>
</table>

<%--
<h4>
    <spring:message code="survey.label.answer"/>: ${answer.description}&nbsp;
    <a href="<portlet:renderURL><portlet:param name="action" value="viewQuestionAnswers"/><portlet:param name="question" value="${answer.question.id}"/></portlet:renderURL>"><img title="<spring:message code="questionAnswers.view.button"/>" src="<html:imagesPath/>view.png" border=0 /></a>
</h4>
<h4>
    <spring:message code="survey.label.question"/>: ${answer.question.description}&nbsp;
    <a href="<portlet:renderURL><portlet:param name="action" value="viewSurveyQuestions"/><portlet:param name="survey" value="${question.survey.id}"/></portlet:renderURL>"><img title="<spring:message code="surveyQuestions.view.button"/>" src="<html:imagesPath/>view.png" border=0 /></a>
</h4>
 --%>



<div class="lfr-separator">&nbsp;</div>

<div class="portlet-body">

    <table class="lfr-table">
        <tr>
            <th><spring:message code="item.number"/></th>
            <th><spring:message code="answer.label.description"/></th>
        </tr>
    <c:set var="counter" value="${firstElemIdx + 1}" />
    <c:forEach items="${pagedListHolder.pageList}" var="userDesc">
        <tr>
            <td>${counter}</td>
            <td><c:out value="${fn:replace(userDesc, newLineChar, newLineHtml)}" escapeXml="false" /></td>
        </tr>
    <c:set var="counter" value="${counter + 1}" />
    </c:forEach>
    </table>

<div class="lfr-separator">&nbsp;</div>

<%-- // load our paging tag, pass pagedListHolder and the link --%>
<tg:paging pagedListHolder="${pagedListHolder}" pagedLink="${pagedLink}"/>

</div>

<div class="lfr-separator">&nbsp;</div>

<div class="lfr-toolbar">
    <a href="<portlet:renderURL><portlet:param name="action" value="viewQuestionAnswers"/><portlet:param name="questionID" value="${answer.question.id}"/></portlet:renderURL>"><img title="<spring:message code="questionAnswers.view.button"/>" src="<html:imagesPath/>view-answers.png" border=0 /></a>&nbsp;
    <a href="<portlet:renderURL><portlet:param name="action" value="viewSurveyQuestions"/><portlet:param name="surveyID" value="${answer.question.survey.id}"/></portlet:renderURL>"><img title="<spring:message code="surveyQuestions.view.button"/>" src="<html:imagesPath/>view-questions.png" border=0 /></a>&nbsp;
    <a href="<portlet:renderURL portletMode="view"/>"><img title="<spring:message code="button.home"/>" src="<html:imagesPath/>home.png" border=0 /></a>
</div>
